package cn.wolfcode.p2p.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.DateFormat;
import java.util.Date;
import java.util.HashMap;

/**
 * 视频认证记录(预约)
 */
@Getter
@Setter
public class VideoAuth extends BaseAuditDomain {

    //预约时间段
    private OrderTime orderTime;
    //预约日期
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date orderDate;


    //增加拼接时间的方法 getOrderTimeString
    public String getOrderTimeString() {
        StringBuilder builder = new StringBuilder();
        builder.append(DateFormat.getDateInstance().format(orderDate)).
                append(" ").
                append(orderTime.getBegin()).
                append("~").
                append(orderTime.getEnd());
        return builder.toString();
    }

    public String getJsonString() {
        HashMap<Object, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("orderTime", getOrderTimeString());
        map.put("username", applier.getUsername());
        return JSONUtils.toJSONString(map);
    }

}